package com.jtjrenren.android.taxi.driver.bean.api;

import com.library.utils.StringUtils;

/**
 * Created by Administrator on 2016/3/7.
 */
public class AppVersion {

    /**
     * VersionNo : 2.0.5
     * Introductions : 1.修复功能的某些bug 2.优化了系统
     * PlatForm : Android
     * DownloadHttp : http://192.168.1.119:8032/UpDoc/APK/android.gmail_0246.apk
     * FileSize : 2.5M
     * IsUpdate : 0
     */

    public static final int APP_UPDATE_NO = 0;
    public static final int APP_UPDATE_NEED = 1;
    public static final int APP_UPDATE_FORCE = 2;

    private String VersionNo;
    private String Introductions;
    private String PlatForm;
    private String DownloadHttp;
    private String FileSize;
    private String IsUpdate;

    /**
     * 检查app 是否需要更新
     *
     * @param versionMsg
     * @return
     */
    public int compareVersion(String versionMsg) {
        if (StringUtils.isEmpty(IsUpdate))
            IsUpdate = "0";
        int upMode = APP_UPDATE_NO;
        if (!StringUtils.isEmpty(VersionNo)) {
            String[] nowVersion = versionMsg.split("\\.");
            String[] webVersion = VersionNo.split("\\.");
            for (int i = 0; i < 3; i++) {
                if (Integer.parseInt(webVersion[i]) > Integer.parseInt(nowVersion[i])) {
                    upMode = APP_UPDATE_NEED;
                }
            }
        }
        if (upMode == APP_UPDATE_NEED && Integer.parseInt(IsUpdate) == 1)
            upMode = APP_UPDATE_FORCE;

        return upMode;
    }

    public void setVersionNo(String VersionNo) {
        this.VersionNo = VersionNo;
    }

    public void setIntroductions(String Introductions) {
        this.Introductions = Introductions;
    }

    public void setPlatForm(String PlatForm) {
        this.PlatForm = PlatForm;
    }

    public void setDownloadHttp(String DownloadHttp) {
        this.DownloadHttp = DownloadHttp;
    }

    public void setFileSize(String FileSize) {
        this.FileSize = FileSize;
    }

    public void setIsUpdate(String IsUpdate) {
        this.IsUpdate = IsUpdate;
    }

    public String getVersionNo() {
        return VersionNo;
    }

    public String getIntroductions() {
        return Introductions;
    }

    public String getPlatForm() {
        return PlatForm;
    }

    public String getDownloadHttp() {
        return DownloadHttp;
    }

    public String getFileSize() {
        return FileSize;
    }

    public String getIsUpdate() {
        return IsUpdate;
    }
}
